MODULE qcim_scheme_module

   USE qcim_global_consts
   USE qcim_global_types

   IMPLICIT NONE
   PRIVATE
   ! Public procedures
   PUBLIC :: qcim_init_scheme,  &
             qcim_get_scheme

   ! "scheme" contains all the input (and default) parameter data to 
   ! completely define a unique MM run-type
   TYPE(qcim_scheme), TARGET, SAVE :: scheme

   ! Safety check for initialisation
   LOGICAL, SAVE :: scheme_initialised = .FALSE.

CONTAINS

!-------------------------------------------------------------------------------
      
   SUBROUTINE qcim_get_scheme(scheme_ptr)

      IMPLICIT NONE
      TYPE(qcim_scheme), POINTER :: scheme_ptr

      IF (.NOT. scheme_initialised) STOP 'qcim scheme uninitialised!'

      NULLIFY(scheme_ptr)
      scheme_ptr => scheme 

   END SUBROUTINE qcim_get_scheme

!-------------------------------------------------------------------------------

   SUBROUTINE qcim_init_scheme(job_type,ndim)

      IMPLICIT NONE
      INTEGER(INTK), INTENT(IN) :: job_type
      INTEGER(INTK), INTENT(IN) :: ndim(3)

      scheme%nbpoints = PRODUCT( ndim(1:3) ) - PRODUCT( ndim(1:3)-2 )
      scheme_initialised = .TRUE.

   END SUBROUTINE qcim_init_scheme

!-------------------------------------------------------------------------------

END MODULE qcim_scheme_module
